package sz.com.postoffice.jxyzwgcase.core;

import java.io.Serializable;

public class BaseResponseEntity implements Serializable{
	private static final long serialVersionUID = 1L;
		private Integer code;
	    private String msg;
	    private Object data;
	    public BaseResponseEntity() {}

	    public BaseResponseEntity(Integer code, String msg) {
	        this.code = code;
	        this.msg = msg;
	    }

	    public static BaseResponseEntity success() {
	    	BaseResponseEntity result = new BaseResponseEntity();
	        result.setResultCode(ResultCode.SUCCESS);
	        return result;
	    }

	    public static BaseResponseEntity success(Integer code, String msg,Object data) {
	    	BaseResponseEntity result = new BaseResponseEntity();
	        result.setCode(code);
	        result.setMsg(msg);
	        result.setData(data);
	        return result;
	    }
	    
	    public static BaseResponseEntity success(Object data) {
	    	BaseResponseEntity result = new BaseResponseEntity();
	        result.setResultCode(ResultCode.SUCCESS);
	        result.setData(data);
	        return result;
	    }

	    public static BaseResponseEntity failure(ResultCode resultCode) {
	    	BaseResponseEntity result = new BaseResponseEntity();
	        result.setResultCode(resultCode);
	        return result;
	    }

	    public static BaseResponseEntity failure(ResultCode resultCode, Object data) {
	    	BaseResponseEntity result = new BaseResponseEntity();
	        result.setResultCode(resultCode);
	        result.setData(data);
	        return result;
	    }

	    public void setResultCode(ResultCode code) {
	        this.code = code.code();
	        this.msg = code.message();
	    }

	    public Integer getCode() {
	        return this.code;
	    }

	    public void setCode(final Integer code) {
	        this.code = code;
	    }

	    public String getMsg() {
	        return this.msg;
	    }

	    public void setMsg(final String msg) {
	        this.msg = msg;
	    }

	    public Object getData() {
	        return this.data;
	    }

	    public void setData(final Object data) {
	        this.data = data;
	    }

}
